using System;
using System.Collections.Generic;
using System.Text;

namespace ASBCC.Workflow.K2Manager
{
    public static class K2Config
    {
        public static System.Collections.Specialized.NameValueCollection AppSettings { get { return System.Configuration.ConfigurationManager.AppSettings; } }

        //add by dengtk 20100609
        public static int K2GetWoekItemRetryTimes 
        { 
            get 
            {
                int res = 3;
                if (AppSettings["K2GetWoekItemRetryTimes"] != null && !string.IsNullOrEmpty(AppSettings["K2GetWoekItemRetryTimes"]))
                {
                    try
                    {
                        res = int.Parse(AppSettings["K2GetWoekItemRetryTimes"]);
                    }
                    catch(Exception ex)
                    {
                        res = 3;
                    }
                }
                return res; 
            } 
        }
        public static int K2GetWorkItemDelaySecond
        {
            get
            {
                int res = 1;
                if (AppSettings["K2GetWorkItemDelaySecond"] != null && !string.IsNullOrEmpty(AppSettings["K2GetWorkItemDelaySecond"]))
                {
                    try
                    {
                        res = int.Parse(AppSettings["K2GetWorkItemDelaySecond"]);
                    }
                    catch (Exception ex)
                    {
                        res = 1;
                    }
                }
                return res;
            }
        }

        public static string K2Server { get { return AppSettings["K2Server"]; } }
        public static uint K2Port
        { 
            get 
            { 
                string k2Port = AppSettings["K2Port"];
                uint port;
                bool res = uint.TryParse(k2Port, out port);
                if (res) return port;
                return 5252;
            } 
        }
        public static uint K2MgmtPort
        {
            get
            {
                string k2Port = AppSettings["K2MgmtPort"];
                uint port;
                bool res = uint.TryParse(k2Port, out port);
                if (res) return port;
                return 5555;
            }
        }
        public static string K2DomainName { get { return AppSettings["K2DomainName"]; } }        
        public static string K2AdminName { get { return AppSettings["K2AdminName"]; } }
        public static string K2AdminPassword { get { return AppSettings["K2AdminPassword"]; } }
        public static string K2DBConnectionString { get { return AppSettings["K2DBConnectionString"]; } }
        public static string K2ProcessFolder { get { return AppSettings["K2ProcessFolder"]; } }

    }
}
